package de.baumann.browser.api.net.util;

import java.util.List;
import java.util.Map;
import java.util.Set;

import de.baumann.browser.api.net.GoOdinApiService;
import de.baumann.browser.api.net.OtherApiService;
import de.baumann.browser.api.net.base.ApiBuilder;
import de.baumann.browser.api.net.vo.HaseValueSet;
import de.baumann.browser.api.net.vo.HashFormat;
import de.baumann.browser.api.net.vo.LockStatus;
import de.baumann.browser.api.net.vo.LoginInfo;
import de.baumann.browser.api.net.vo.Notice;
import de.baumann.browser.api.net.vo.OdinOre;
import de.baumann.browser.api.net.vo.OdinWithdrawRecord;
import de.baumann.browser.api.net.vo.RechargeInfo;
import de.baumann.browser.api.net.vo.Result;
import de.baumann.browser.api.net.vo.Steal;
import de.baumann.browser.api.net.vo.Version;
import de.baumann.browser.api.net.vo.Weather;
import io.reactivex.Observable;
import retrofit2.Callback;

/**
 * @author：
 * @date：2018/11/29
 * @discription: 广告，算力，提现....等 接口工具类
 **/
public class OtherHttpUtil {

    private static OtherApiService otherApiService;
    private static GoOdinApiService goOdinApiService;

    static {
        otherApiService = ApiBuilder.buildService(OtherApiService.class);
        goOdinApiService = ApiBuilder.buildService(GoOdinApiService.class);
    }


    /**
     * 替换所有规则
     *
     * @param callback 回调
     */
    public static void androidAdRules(Callback<Map<String, List<Object>>> callback) {
        goOdinApiService.androidAdRules().enqueue(callback);
    }

    /**
     * 广告过滤
     *
     * @param callback 回调
     */
    public static void filterUrls(Callback<Set<String>> callback) {
        goOdinApiService.filterUrls().enqueue(callback);
    }

    /**
     * 注册 获取验证码
     *
     * @param phone 手机号
     * @return Observable
     */
    public static Observable<Result> registerGetSmsCode(String phone,String token) {
        return otherApiService.registerGetSmsCode(phone, 1, token,86);
    }

    /**
     * 忘记密码
     *
     * @param phone
     * @return
     */
    public static Observable<Result> retrieveGetSmsCode(String phone,String token) {
        return otherApiService.registerGetSmsCode(phone, 4, token,86);
    }


    /**
     * 意见反馈
     *
     * @param title   标题
     * @param content 内容
     * @return Observable
     */
    public static Observable<Result> feedback( String title, String content) {
        return otherApiService.feedback(title, content);
    }


    /**
     * 版本更新
     *
     * @return Observable
     */
    public static Observable<Result<Version>> updateVersion() {
        return otherApiService.updateVersion();
    }


    /**
     * 获取算礼包规格
     * @return
     */
    public static Observable<Result<List<HashFormat>>> getHashFormat() {
        return otherApiService.getHashFormats();
    }


    /**
     * 获取算力值 增加记录
     * @param licence
     * @param startPage
     * @return
     */
    public static Observable<Result<HaseValueSet>> getHashRecord(String licence, int startPage) {
        return otherApiService.getHashRecord( licence, startPage, 50);
    }


    /**
     * 获取矿石
     * @param licence
     * @return
     */
    public static Observable<Result<List<OdinOre>>> getOdinOres(String licence) {
        return otherApiService.getOdinOres(licence);
    }

    /**
     * 收取矿石
     * @param oreId
     * @return
     */
    public static Observable<Result> gatherOre(String oreId) {
        return otherApiService.gatherOre(oreId);
    }

    /**
     *获取提现记录
     * @return
     */
    public static Observable<Result<List<OdinWithdrawRecord>>> getWithdrawRecord() {
        return otherApiService.getWithdrawRecord();
    }

    /**
     * 获取短信验证码
     * @param phone
     * @param type
     * @return
     */
    public static Observable<Result> getSmsCode(String phone, int type,String token) {
        return otherApiService.getSmsCode(phone, 86,token,type);
    }

    /**
     * 获取算力排名
     * @return
     */
    public static Observable<Result<List<LoginInfo>>> getHashRanking() {
        return otherApiService.getHashRanking();
    }

    /**
     * 提现
     * @param amount
     * @param code
     * @return
     */
    public static Observable<Result> withdraw(String amount, String code) {
        return otherApiService.withdraw(amount, 1, 86,code);
    }


    /**
     * 获取通知公告
     * @return
     */
    public static Observable<Result<List<Notice>>> getNotice() {
        return otherApiService.getNotice();
    }

    /**
     * 阅读公告
     * @param noticeId
     * @return
     */
    public static Observable<Result> noticeRead( String noticeId) {
        return otherApiService.noticeRead( noticeId);
    }

    /**
     * 获取充值地址
     * @return
     */
    public static Observable<Result<RechargeInfo>> getRechargeAddress() {
        return otherApiService.getRechargeAddress();
    }

    public static Observable<Result<Weather>> getWeather(String city) {
        return otherApiService.getWeather(city);
    }

    public static Observable<Result<List<Steal>>> getCanStealList() {
        return otherApiService.getCanStealList();
    }

    public static Observable<Result<LockStatus>> getGameStatus() {
        return otherApiService.getGameStatus();
    }

    public static Observable<Result<LockStatus>> setGameStatus() {
        return otherApiService.setGameStatus();
    }

    public static Observable<Result<List<Steal>>> getOftenStealList() {
        return otherApiService.getOftenStealList();
    }


}
